﻿@using ToyStore.Web.Mvc.Authentication
@using ToyStore.Web.Mvc.Common

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl"> 

<head>
    @*<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />*@
    
    <link href="@Url.Content("~/Content/main.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/smoothness/jquery-ui-1.8.17.custom.css")" rel="stylesheet" type="text/css" />
    
	<script src="@Url.Content("/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
	<script src="@Url.Content("/Scripts/BootstrapScripts2.0.0.34/bootstrap-tooltip.js")" type="text/javascript"></script>
    <script src="@Url.Content("/Scripts/BootstrapScripts2.0.0.34/bootstrap-transition.js")" type="text/javascript"></script>
    <script src="@Url.Content("/Scripts/BootstrapScripts2.0.0.34/bootstrap-carousel.js")" type="text/javascript"></script>
    <script src="@Url.Content("/Scripts/jquery-ui-1.8.17.custom.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("/Scripts/jQuery.tmpl.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("/Scripts/toystore.main.js")" type="text/javascript"></script>
    <title>@ViewBag.Title</title>    
</head>
<script type="text/javascript">
    $(document).ready(function () {

        $('[rel="tooltip"]').tooltip("hide");


        //Adding autocomplete to region input
        $("#searchTexbox").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: '@Url.Action("SearchProductsAjax", "Product")',
                    dataType: "json",
                    data: {
                        term: request.term
                    },
                    success: function (data) {
                        response($.map(data, function (item) {

                            return {
                                name: item.Name,
                                id: item.Id,
                                price: item.PriceNetto,
                                img: item.Url
                            }
                        }));
                    }
                });
            },
            select: function (event, ui) {
                $("#searchTexbox").val(ui.item.name);
                location = '/Product/Details/' + ui.item.id;
                return false;
            },
            minLength: 2

        }).data("autocomplete")._renderItem = function (ul, item) {

            var result = $("#searchProductTemplate").tmpl(item);
            var listItem = $("<li></li>")
				.data("item.autocomplete", item)
                .append(result)
				.appendTo(ul);

            return listItem;
        };


    });
    
</script>
<script id="searchProductTemplate" type="text/x-jquery-tmpl">
    <a style="cursor: pointer">
    <table>
        <tr>
            <td style="width:40px;"><img class="productIco" src="${img}"></img></td>
            <td style="max-width:340px;">${name}</td>
            <td><h4>${price} zł</h4></td>
        </tr>
    </table>
    </a>
    <li></li>
</script>
<body>

	<div class="page">
		<div id="page-message-contener">
			@if (ViewContext.TempData[ActionConfirmation.TempDataKey] != null)
			{
				var confirm = (ActionConfirmation) ViewContext.TempData[ActionConfirmation.TempDataKey];
				<div id="page-message">
					<div id="@(confirm.WasSuccessful ? "page-message-success" : "page-message-error")">@(confirm.Message)</div>
				</div>
			}
            <div id="ajaxloader"></div>
		</div>
        <div id="topContainer">
         <div class="pull-right" style="margin-top: 5px">
			@if (RightPrincipal.CurrentUser == null)
			{
				using (Html.BeginForm("LogOn", "Home", FormMethod.Post))
				{
					<div>
						@(Html.ActionLink<HomeController>(c => c.LogOnPage(null), "Zaloguj się")) |
						@(Html.ActionLink<HomeController>(c => c.LogOnPage(null), "Zarejestruj się"))
					</div>
				}
			}
			else
			{
				<div>Witaj, @RightPrincipal.CurrentUser.FullName @Html.ActionLink("Wyloguj", "LogOut", "Home")</div>
				<div>@(Html.ActionLink<ProductController>(c => c.YourShelf(1, 10), "Twoja półka")) | @(Html.ActionLink<HomeController>(c => c.Index(), "Profil")) </div>
			}
			</div>
        <div id="logo"></div>
        <div id="searchContainer">
            <div id="searchContainerTittle" class="pull-left"><span style="margin-top: 15px; margin-left: 15px; display : block;">Szukaj książki</span></div>
            <div id="searchInputContainer" class="pull-left"><input type="text" id="searchTexbox" class="span5"/></div>
        </div>
        </div>
        <div id="navigationMenuContainer" style="height: 63px;">
            <div id="menu">
                <ul class="unstyled">
                    <li>@(Html.ActionLink<HomeController>(x => x.Index(),"home"))</li>
                    <li><a>promocje</a></li>
                    <li><a>nowości</a></li>
                    <li><a>wyprzedaż</a></li>
					<li><a>bestsellery</a></li>
					<li><a>dlaczego u nas</a></li>
                    <li><a>kontakt</a></li>
                </ul>
            </div>
			@{
				Html.RenderAction<HomeController>(c => c.CartDetails());
			}
		</div>
        <div id="pageContent">
            <div id="leftMenu">
            @(Html.Action("GenerateCategoryMenu", "Category"))
            </div>
            <div id="pageBody">
        
             @* Treść strony *@
			    @RenderBody()
        
            </div>
            
            <div style="clear: both"></div>
            
        </div>
        <div class="footerContainer">
        
        
        </div>
	
	  </div>
  
</body>
</html>
